package com.lbjhan.rpc.consumer;

import com.lbjhan.rpc.consumer.server.RpcNettyRequestServer;
import com.lbjhan.rpc.consumer.server.RpcNettyServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ServerBootstrapApplication implements CommandLineRunner {

//    @Autowired
//    RpcNettyServer rpcNettyServer;

    @Autowired
    RpcNettyRequestServer rpcNettyRequestServer;

    public static void main(String[] args) {
        SpringApplication.run(ServerBootstrapApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        new Thread(new Runnable() {
            @Override
            public void run() {
//                rpcNettyServer.startServer("127.0.0.1", 9091);
                rpcNettyRequestServer.startServer("127.0.0.1", 9091);
            }
        }).start();
    }
}
